package com.spring.demo.rabbit.config;

import com.spring.demo.rabbit.QueueConst;
import org.springframework.amqp.core.AmqpAdmin;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.core.QueueBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.annotation.Resource;

/***
 * @title SimpleQueue
 * @description
 * @author baiji
 * @version 1.0.0
 * @create 2023/9/4 11:08
 **/
@Configuration
public class SimpleQueueConfig {

    @Resource
    private AmqpAdmin amqpAdmin;

    /**
     * 声明一个队列
     *
     * @return
     */
    @Bean
    public Queue simpleQueue() {
        Queue simpleQueue = QueueBuilder.durable(QueueConst.SIMPLE_QUEUE).build();
        amqpAdmin.declareQueue(simpleQueue);
        return simpleQueue;
    }
}
